# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=python-pgcli
pkgname=('python2-pgcli' 'python-pgcli')
_pkgname=pgcli
pkgver=4.3.0
pkgrel=1
pkgdesc='CLI for Postgres Database. With auto-completion and syntax highlighting.'
arch=('any')
url='https://pypi.org/project/pgcli/#files'
license=('BSD')
makedepends=('python2-setuptools' 'python-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('cc314386a5760c555b27b7f278cb65af902a5a255d99807b274648c79b7606101f83dca7fc6c6bb3bd565146ca5948c01b2ac19f9ac36fb3bda4e9e8e0ab3187')

prepare() {
  cp -a "$_pkgname-$pkgver"{,-2}
}

build() {
  cd "$_pkgname-$pkgver-2"

  python2 setup.py build

  cd "$srcdir/$_pkgname-$pkgver"

  python setup.py build
}

package_python2-pgcli() {
  depends=('python2' 'python2-click' 'python2-pygments' 'python2-psycopg2'
           'python2-sqlparse' 'python2-configobj' 'python2-pgspecial'
           'python2-setproctitle' 'python2-cli-helpers' 'python2-humanize')

  cd "$_pkgname-$pkgver-2"

  python2 setup.py install --prefix=/usr --root="$pkgdir" --optimize=1 \
    --skip-build

  mv "$pkgdir/usr/bin/$_pkgname" "$pkgdir/usr/bin/${_pkgname}-2"
}

package_python-pgcli() {
  depends=('python' 'python-click' 'python-pygments' 'python-psycopg2'
           'python-sqlparse' 'python-configobj' 'python-pgspecial'
           'python-setproctitle' 'python-cli-helpers' 'python-humanize')

  cd "$_pkgname-$pkgver"

  python setup.py install --prefix=/usr --root="$pkgdir" --optimize=1 \
    --skip-build
}

